#include "AutoSplitterHandle.h"
#include <QtGui/QPalette>

AutoSplitterHandle::AutoSplitterHandle(Qt::Orientation orientation,QSplitter *parent)
	: QSplitterHandle(orientation,parent),_defaultHandleWidth(4)
{
	this->setBackgroundRole(QPalette::Light);
}

AutoSplitterHandle::~AutoSplitterHandle()
{

}

void AutoSplitterHandle::mouseReleaseEvent( QMouseEvent * event ){
	this->splitter()->setHandleWidth(_defaultHandleWidth);
	//setBackgroud(Qt::white);
	this->setBackgroundRole(QPalette::Light);
	QWidget::mouseReleaseEvent(event);
}

void AutoSplitterHandle::setBackgroud(QColor color){
	this->setBackgroundRole(QPalette::Dark);
	QPalette palette;	
	palette.setBrush(QPalette::Background,QBrush(color));
	this->setPalette(palette);
}

void AutoSplitterHandle::resizeHandleWidth(){
	//setBackgroud(Qt::black);
	this->setBackgroundRole(QPalette::Shadow);
	if(this->splitter()->handleWidth()==_defaultHandleWidth)
		this->splitter()->setHandleWidth(_defaultHandleWidth*5);
}
